CXX = g++
FRAMEWORKS = -F../lib/frameworks/ -framework Ogre -framework IOKit -framework Carbon
CXXFLAGS = -O2 $(FRAMEWORKS) -U_OgreOctreePluginExport -D_OgreOctreePluginExport= -I../lib/include/ -I../lib/include/IrrKlang/ -I../lib/include/QuickGUI/ -I../lib/frameworks/Ogre.framework/Versions/1.7.1/Headers/ -Iinclude/ -Iinclude/gen/ -arch i386 -m32
LINK = $(FRAMEWORKS) ../lib/frameworks/Plugins/Plugin_OctreeSceneManager.dylib -L../lib/bin -L../lib/bin/boost -lboost_filesystem -lquickgui -lstdc++ -lboost_signals -lboost_system -lboost_date_time -lboost_regex -lboost_serialization -lboost_thread -lboost_wserialization -lOIS -lprotobuf -lirrklang -arch i386 -m32
SRC = src/
INC = include/

spelprog2: BundleInfo.o CameraMan.o Client.o ClientLogic.o Connection.o EntityInterpolator.o Faction.o FrameHandler.o Game.o GameGUI.o Landscape.o Local.o main.o MenuGUI.o MenuNetLogic.o MenuPresentation.o MessageFile.o Net.o NetVars.o PathFinder.o Projectile.o Server.o ServerLogic.o SimNetLogic.o SmoothFloat.o Squad.o SquadSelection.o UglyDebug.o Unit.o UnitInterpolator.o UnitInvariant.o WidgetRegistry.o World.o WorldGUI.o WorldInputHandler.o WorldPresentation.o WorldScene.o auxmsg.pb.o netmsg.pb.o savemsg.pb.o
	$(CXX) $(LINK) BundleInfo.o CameraMan.o Client.o ClientLogic.o Connection.o EntityInterpolator.o Faction.o FrameHandler.o Game.o GameGUI.o Landscape.o Local.o main.o MenuGUI.o MenuNetLogic.o MenuPresentation.o MessageFile.o Net.o NetVars.o PathFinder.o Projectile.o Server.o ServerLogic.o SimNetLogic.o SmoothFloat.o Squad.o SquadSelection.o UglyDebug.o Unit.o UnitInterpolator.o UnitInvariant.o WidgetRegistry.o World.o WorldGUI.o WorldInputHandler.o WorldPresentation.o WorldScene.o auxmsg.pb.o netmsg.pb.o savemsg.pb.o -o spelprog2

BundleInfo.o: $(SRC)BundleInfo.cpp $(INC)BundleInfo.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)BundleInfo.cpp

CameraMan.o: $(SRC)CameraMan.cpp $(INC)CameraMan.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)CameraMan.cpp

Client.o: $(SRC)Client.cpp $(INC)Client.hpp $(INC)ClientLogic.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)Client.cpp

ClientLogic.o: $(SRC)ClientLogic.cpp $(INC)ClientLogic.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)ClientLogic.cpp

Connection.o: $(SRC)Connection.cpp $(INC)Connection.hpp $(INC)Net.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)Connection.cpp

EntityInterpolator.o: $(SRC)EntityInterpolator.cpp $(INC)EntityInterpolator.hpp $(INC)HelpDefs.hpp $(INC)Landscape.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)EntityInterpolator.cpp

Faction.o: $(SRC)Faction.cpp $(INC)Faction.hpp $(INC)World.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)Faction.cpp

FrameHandler.o: $(SRC)FrameHandler.cpp $(INC)FrameHandler.hpp $(INC)CameraMan.hpp $(INC)Game.hpp $(INC)GameGUI.hpp $(INC)Net.hpp $(INC)Presentation.hpp $(INC)WorldInputHandler.hpp $(INC)WorldManager.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)FrameHandler.cpp

Game.o: $(SRC)Game.cpp $(INC)Game.hpp $(INC)CameraMan.hpp $(INC)Client.hpp $(INC)FrameHandler.hpp $(INC)GameGUI.hpp $(INC)Local.hpp $(INC)MenuPresentation.hpp $(INC)Net.hpp $(INC)Server.hpp $(INC)WorldManager.hpp $(INC)BundleInfo.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)Game.cpp

GameGUI.o: $(SRC)GameGUI.cpp $(INC)GameGUI.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)GameGUI.cpp

Landscape.o: $(SRC)Landscape.cpp $(INC)Landscape.hpp $(INC)PathFinder.hpp $(INC)BundleInfo.hpp $(INC)FixedTerrainHeader.hpp $(INC)HelpDefs.hpp $(INC)PresentationDefs.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)Landscape.cpp

Local.o: $(SRC)Local.cpp $(INC)Local.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)Local.cpp

main.o: $(SRC)main.cpp $(INC)Game.hpp $(INC)MessageRegisters.hpp $(INC)BundleInfo.hpp $(INC)NetDefs.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)main.cpp

MenuGUI.o: $(SRC)MenuGUI.cpp $(INC)MenuGUI.hpp $(INC)Game.hpp $(INC)FileDefs.hpp $(INC)MenuNetLogic.hpp $(INC)MessageFile.hpp $(INC)WorldManager.hpp $(INC)WorldPresentation.hpp $(INC)BundleInfo.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)MenuGUI.cpp

MenuNetLogic.o: $(SRC)MenuNetLogic.cpp $(INC)MenuNetLogic.hpp $(INC)Game.hpp $(INC)MenuGUI.hpp $(INC)WorldManager.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)MenuNetLogic.cpp

MenuPresentation.o: $(SRC)MenuPresentation.cpp $(INC)MenuPresentation.hpp $(INC)CameraMan.hpp $(INC)FixedTerrainHeader.hpp $(INC)Game.hpp $(INC)MenuGUI.hpp $(INC)MenuNetLogic.hpp $(INC)WorldManager.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)MenuPresentation.cpp

MessageFile.o: $(SRC)MessageFile.cpp $(INC)MessageFile.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)MessageFile.cpp

Net.o: $(SRC)Net.cpp $(INC)Net.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)Net.cpp

NetVars.o: $(SRC)NetVars.cpp $(INC)NetVars.hpp $(INC)Net.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)NetVars.cpp

PathFinder.o: $(SRC)PathFinder.cpp $(INC)PathFinder.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)PathFinder.cpp

Projectile.o: $(SRC)Projectile.cpp $(INC)Projectile.hpp $(INC)Landscape.hpp $(INC)UnitInvariant.hpp $(INC)World.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)Projectile.cpp

Server.o: $(SRC)Server.cpp $(INC)Server.hpp $(INC)HelpDefs.hpp $(INC)ServerLogic.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)Server.cpp

ServerLogic.o: $(SRC)ServerLogic.cpp $(INC)ServerLogic.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)ServerLogic.cpp

SimNetLogic.o: $(SRC)SimNetLogic.cpp $(INC)SimNetLogic.hpp $(INC)Faction.hpp $(INC)MessageFile.hpp $(INC)Spatial.hpp $(INC)World.hpp $(INC)WorldManager.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)SimNetLogic.cpp

SmoothFloat.o: $(SRC)SmoothFloat.cpp $(INC)SmoothFloat.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)SmoothFloat.cpp

Squad.o: $(SRC)Squad.cpp $(INC)Squad.hpp $(INC)UnitInvariant.hpp $(INC)World.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)Squad.cpp

SquadSelection.o: $(SRC)SquadSelection.cpp $(INC)SquadSelection.hpp $(INC)Faction.hpp $(INC)World.hpp $(INC)WorldManager.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)SquadSelection.cpp

UglyDebug.o: $(SRC)UglyDebug.cpp $(INC)PresentationDefs.hpp $(INC)UglyDebug.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)UglyDebug.cpp

Unit.o: $(SRC)Unit.cpp $(INC)Unit.hpp $(INC)Landscape.hpp $(INC)Squad.hpp $(INC)UnitInvariant.hpp $(INC)World.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)Unit.cpp

UnitInterpolator.o: $(SRC)UnitInterpolator.cpp $(INC)UnitInterpolator.hpp $(INC)PresentationDefs.hpp $(INC)UnitInvariant.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)UnitInterpolator.cpp

UnitInvariant.o: $(SRC)UnitInvariant.cpp $(INC)UnitInvariant.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)UnitInvariant.cpp

WidgetRegistry.o: $(SRC)WidgetRegistry.cpp $(INC)WidgetRegistry.hpp $(INC)HelpDefs.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)WidgetRegistry.cpp

World.o: $(SRC)World.cpp $(INC)World.hpp $(INC)WorldManager.hpp $(INC)BundleInfo.hpp $(INC)Faction.hpp $(INC)FileDefs.hpp $(INC)Game.hpp $(INC)MessageFile.hpp $(INC)Landscape.hpp $(INC)Presentation.hpp $(INC)SimNetLogic.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)World.cpp

WorldGUI.o: $(SRC)WorldGUI.cpp $(INC)WorldGUI.hpp $(INC)Game.hpp $(INC)SquadSelection.hpp $(INC)WorldManager.hpp $(INC)WorldScene.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)WorldGUI.cpp

WorldInputHandler.o: $(SRC)WorldInputHandler.cpp $(INC)WorldInputHandler.hpp $(INC)CameraMan.hpp $(INC)EntityInterpolator.hpp $(INC)Game.hpp $(INC)Net.hpp $(INC)Presentation.hpp $(INC)PresentationDefs.hpp $(INC)WorldManager.hpp $(INC)WorldScene.hpp $(INC)Faction.hpp $(INC)Landscape.hpp $(INC)UglyDebug.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)WorldInputHandler.cpp

WorldPresentation.o: $(SRC)WorldPresentation.cpp $(INC)WorldPresentation.hpp $(INC)CameraMan.hpp $(INC)FixedTerrainHeader.hpp $(INC)Game.hpp $(INC)WorldInputHandler.hpp $(INC)WorldGUI.hpp $(INC)WorldScene.hpp $(INC)WorldManager.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)WorldPresentation.cpp

WorldScene.o: $(SRC)WorldScene.cpp $(INC)WorldScene.hpp $(INC)EntityInterpolator.hpp $(INC)Landscape.hpp $(INC)PresentationDefs.hpp $(INC)Projectile.hpp $(INC)UnitInterpolator.hpp $(INC)UnitInvariant.hpp $(INC)World.hpp $(INC)WorldManager.hpp
	$(CXX) $(CXXFLAGS) -c $(SRC)WorldScene.cpp

auxmsg.pb.o: $(SRC)gen/auxmsg.pb.cc $(INC)gen/auxmsg.pb.h
	$(CXX) $(CXXFLAGS) -c $(SRC)gen/auxmsg.pb.cc

netmsg.pb.o: $(SRC)gen/netmsg.pb.cc $(INC)gen/netmsg.pb.h
	$(CXX) $(CXXFLAGS) -c $(SRC)gen/netmsg.pb.cc

savemsg.pb.o: $(SRC)gen/savemsg.pb.cc $(INC)gen/savemsg.pb.h
	$(CXX) $(CXXFLAGS) -c $(SRC)gen/savemsg.pb.cc

package_clean:
	rm -f -R sandbox
	
package_update: spelprog2
	cp spelprog2 sandbox/Contents/MacOS

package: spelprog2
	mkdir -p sandbox/Contents/MacOS
	mkdir -p sandbox/Contents/Frameworks
	mkdir -p sandbox/Contents/Resources
	cp spelprog2 sandbox/Contents/MacOS
	cp ../lib/bin/libquickgui.dylib sandbox/Contents/Frameworks
	cp ../lib/bin/libprotobuf.dylib sandbox/Contents/Frameworks
	cp ../lib/bin/ikpFLAC.dylib sandbox/Contents/MacOS
	cp ../lib/bin/ikpMP3.dylib sandbox/Contents/MacOS
	cp ../lib/bin/libirrklang.dylib sandbox/Contents/Frameworks
	cp -R ../lib/frameworks/Ogre.framework sandbox/Contents/Frameworks
	cp -R ../lib/frameworks/Cg.framework sandbox/Contents/Frameworks
	cp -R ../lib/frameworks/Plugins sandbox/Contents/
	cp -R scripts sandbox
	cp -R media sandbox
	
clean:
	rm *.o

